package com.linsen.core.log.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 记录日志类型
 *
 * @author zhaoyong
 * @date 2023/3/14
 */
@Getter
@AllArgsConstructor
public enum LogStorageType {

    LOGGER("logger", "记录日志"),
    HTTP("http", "记录日志发送至HTTP"),
    RABBITMQ("rabbitmq", "记录日志发送至RABBITMQ"),
    ;

    @JsonValue
    private final String value;
    private final String description;

    private static final Map<String, LogStorageType> VALUES = new HashMap<>();

    static {
        for (final LogStorageType logStorageType : LogStorageType.values()) {
            LogStorageType.VALUES.put(logStorageType.getValue(), logStorageType);
        }
    }

    @JsonCreator
    public static LogStorageType getByValue(String value) {
        return LogStorageType.VALUES.get(value);
    }
}
